package com.hmall.item.utils;

/**
 * @Description MyThreadLoacl
 * @Author GGBond
 * @Date 2024-11-16
 */
public class MyThreadLoacl {
    private static final ThreadLocal<String> threadLocal=new ThreadLocal<>();

    // 提供线程局部变量set方法
    public static void setSubject(String subject) {

        threadLocal.set(subject);
    }
    // 提供线程局部变量get方法
    public static String getSubject() {

        return threadLocal.get();
    }

    //清空当前线程，防止内存溢出
    public static void removeSubject() {

        threadLocal.remove();
    }
}
